package com.ourteam.product.model.api;

import org.apache.commons.lang.BooleanUtils;

import com.ourteam.product.model.domain.ProductModelPropertyBean;
import com.ourteam.product.model.service.IProductModelService;
import com.ourteam.product.model.service.ProductModelServiceFactory;

public class ProductModelPropertyHelper {

	static final IProductModelService PRODUCT_MODEL_SERVICE = ProductModelServiceFactory.getProductModelService();

	private ProductModelPropertyBean modelPropertyBean;

	public ProductModelPropertyHelper(ProductModelPropertyBean modelPropertyBean) {
		super();
		this.modelPropertyBean = modelPropertyBean;
	}

	static public ProductModelPropertyHelper getInstance(long id) throws Exception {
		return new ProductModelPropertyHelper(PRODUCT_MODEL_SERVICE.getProductModelPropertyById(id));
	}

	public long getId() {
		return this.modelPropertyBean.getId();
	}

	public String getPropertyName() {
		return this.modelPropertyBean.getPropertyName();
	}

	public String getDataType() {
		return this.modelPropertyBean.getDataType();
	}

	public boolean isAllowNull() {
		return BooleanUtils.toBoolean(this.modelPropertyBean.getIsAllowNull());
	}

	public boolean isArray() {
		return BooleanUtils.toBoolean(this.modelPropertyBean.getIsArray());
	}

	public boolean isAutoInc() {
		return BooleanUtils.toBoolean(this.modelPropertyBean.getIsAutoInc());
	}

	public boolean isUnique() {
		return BooleanUtils.toBoolean(this.modelPropertyBean.getIsUnique());
	}

	public boolean isPrimaryKey() {
		return BooleanUtils.toBoolean(this.modelPropertyBean.getIsPrimaryKey());
	}

	public String getRemarks() {
		return this.modelPropertyBean.getRemarks();
	}

	public String getDefaultValue() {
		return this.modelPropertyBean.getDefaultValue();
	}

}
